const modules = import.meta.glob([
    "../views/**/*.vue"
  ]);
  // 处理数据为树模式
export function toTree(data) {
  let result = []
  if (!Array.isArray(data)) {
    return result
  }
  data.forEach(item => {
    delete item.children;
  });
  let map = {};
  data = data.map(item => {
    let _newItem = Object.assign({}, item)
    _newItem.meta = {
      title: item.title
    };
    _newItem.component = modules[`../views/${item.component}.vue`];
    map[item.name] = _newItem;
    return _newItem
  });
  data.forEach(item => {
    let parent = map[item.parentName];
    if (parent) {
      (parent.children || (parent.children = [])).push(item);
    } else {
      result.push(item);
    }
  });
  return result;
}
export function getRoute(getRoutes, routes) {
  let pr = getRoutes.find((v) => v.name === "layout");
  pr.children = [pr.children[0], ...routes];
  return pr
}
